<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>新增会员</title>
<link href="${rc.getContextPath()}/resources/css/common.css" rel="stylesheet" type="text/css" />

<script type="text/javascript" src="${rc.getContextPath()}/resources/js/jquery.js"></script>
<script type="text/javascript" src="${rc.getContextPath()}/resources/js/common.js"></script>
<script type="text/javascript" src="${rc.getContextPath()}/resources/js/jquery.validate.js"></script>
<script type="text/javascript" src="${rc.getContextPath()}/resources/js/messages_cn.js"></script>
<script type="text/javascript" src="${rc.getContextPath()}/resources/js/input.js"></script>
 <!-- 引入弹出JS begin -->
<script type="text/javascript" src="${rc.getContextPath()}/js/lhgdialog/lhgdialog.min.js?self=true"></script>
<script type="text/javascript">

	jQuery.validator.addMethod("validPassword", function(value, element) { 
		 
		if($("#password").val()== value){
			return true;
		}else{
			return false;
		}
	 
	}, "2次输入的密码不同，请重新输入"); 
	
	var base = '${rc.getContextPath()}';
	function saveMember() {
		var form1 = $("#tableForm");
		form1.submit();
	}
	function myAlert(txt) {
		window.parent.$.dialog({
			lock : true,
			content : txt,
			cancelVal : '确定',
			autoSize : true,
			cancel : function() { //请求成功后处理函数。 
			}
		});
	}
	$(document).ready(function() {
		var msg = $("#msg").val();
		if (msg == "success") {
			$.dialog.alert("保存成功");
		} else if (msg == 'failed') {
			$.dialog.alert("保存失败");
		}

		var $inputForm = $("#tableForm");
		$inputForm.validate({
			errorClass : "fieldError",
			rules : {
				loginName: {
					required:true,
					remote: {
	                    type: "post",
	                    url: "${rc.getContextPath()}/member/admin/ajaxLoginName.html",
	                    data: {
	                    	loginName:function() {
	                            return $("#txtLoginName").val();
	                        }
	                    },
	                    dataType: "html",
	                    dataFilter: function(data, type) {
	                    	eval("var data  = "+data+";");
	                        if (data.msg == "true")
	                            return "true";
	                        else
	                            return data.msg;	                        
	                    }
	                }
					
				},
				password: "required",
				password2: {
					required:true,
					validPassword:true				
				},
				email:'email',
				age:'number'
			}
		});
		
	});
	
	
	function saveMember() {
		$('#tableForm').submit()
	}
	
	function back(){
		$.dialog.tips("返回中,请稍等...",600,"loading.gif");
		window.location.href='list.html ';
	}

</script>
</head>

<body>
	<input type="hidden" id="msg" name="msg" value="${msg!}" />
	<div class="path">
		<a href="#"><b>新增会员</b></a>
	</div>
	<form action="${base!}/member/admin/saveMember.html" method="post" id="tableForm" name="tableForm" enctype="multipart/form-data">
		<table class="input tabContent">
			<tbody>
				<tr>
					<th><span class="requiredField">*</span>会员名称:</th>
					<td>
						<input type="text" name="loginName" value="${member.loginName}" id="txtLoginName"/>
					</td>
				</tr>
				<tr>
					<th><span class="requiredField">*</span>密码:</th>
					<td>
						<input type="password" name="password" value="${member.password}" id="password"/>
					</td>
				</tr>
				<tr>
					<th><span class="requiredField">*</span>确认密码:</th>
					<td>
						<input type="password" name="password2" value="${member.password}"/>
					</td>
				</tr>
				<tr>
					<th>电子邮件:</th>
					<td><input class="w150" type="text" name="email" value="${member.email}" /></td>
				</tr>
				<tr>
					<th>真实姓名:</th>
					<td><input class="w150" type="text" name="realName" value="${member.realName}" /></td>
				</tr>
				<tr>
					<th>性别:</th>
					<td>
						<select name="sex">
							<option value=""></option>
							<option value="1" <#if member.sex=='1'>selected</#if>>男</option>
							<option value="0" <#if member.sex=='0'>selected</#if>>女</option>
						</select>
					</td>
				</tr>
				<tr>
					<th>年龄:</th>
					<td><input class="w150" type="text" name="age" value="${member.age}" maxlength="3"/></td>
				</tr>
				<tr>
					<th>电话:</th>
					<td><input class="w150" type="text" name="telephone" value="${member.telephone}" /></td>
				</tr>
				<tr>
					<th>地址:</th>
					<td><textarea name="address" cols="30" rows="3">${member.address}</textarea></td>
				</tr>
				<tr>
					<th>爱好:</th>
					<td><textarea name="hobby" cols="30" rows="5">${member.hobby}</textarea></td>
				</tr>
				<tr>
					<th>特长:</th>
					<td><textarea name="features" cols="30" rows="5">${member.features}</textarea></td>
				</tr>
				<tr>
					<th>会员简介:</th>
					<td><textarea name="description" cols="30" rows="10">${member.description}</textarea></td>
				</tr>
			</tbody>
		</table>

		<table class="input">
			<colgroup>
				<col width="15%" />
				<col width="35%" />
				<col width="15%" />
				<col width="35%" />
			</colgroup>
			<tr>
				<td></td>
				<td colspan="3">
					<input type="button" class="button" value="保存" onclick="saveMember();" /> 
					<input type="button" id="backButton" class="button" value="返回" onclick="javascript:back()" />
				</td>
			</tr>
		</table>
	</form>
</body>
</html>